<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="Hexo Theme Keep">
    <meta name="description" content="Hexo Theme Keep">
    <meta name="author" content="付心武士">
    
    <title>
        
            unity转OPPO小游戏 |
        
        且乐杯中物
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="/images/logo.svg">
    
<link rel="stylesheet" href="/css/font-awesome.min.css">

    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"example.com","root":"/","language":"en","path":"search.json"};
    KEEP.theme_config = {"toc":{"enable":true,"number":true,"expand_all":true,"init_open":true},"style":{"primary_color":"#0066CC","avatar":"/images/avatar.svg","favicon":"/images/logo.svg","article_img_align":"left","left_side_width":"260px","content_max_width":"920px","hover":{"shadow":false,"scale":false},"first_screen":{"enable":true,"background_img":"/images/bg.svg","description":"Keep writing and Keep loving."},"scroll":{"progress_bar":{"enable":false},"percent":{"enable":false}}},"local_search":{"enable":true,"preload":true},"code_copy":{"enable":true,"style":"default"},"pjax":{"enable":false},"lazyload":{"enable":false},"version":"3.4.5"};
    KEEP.language_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
  </script>
<meta name="generator" content="Hexo 6.0.0"></head>


<body>
<div class="progress-bar-container">
    

    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                且乐杯中物
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                主页
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                归档
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/categories"
                            >
                                分类
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/tags"
                            >
                                标签
                            </a>
                        </li>
                    
                    
                        <li class="menu-item search search-popup-trigger">
                            <i class="fas fa-search"></i>
                        </li>
                    
                </ul>
            </div>
            <div class="mobile">
                
                    <div class="icon-item search search-popup-trigger"><i class="fas fa-search"></i></div>
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">主页</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">归档</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/categories">分类</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/tags">标签</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="article-content-container">

        <div class="article-title">
            <span class="title-hover-animation">unity转OPPO小游戏</span>
        </div>

        
            <div class="article-header">
                <div class="avatar">
                    <img src="/images/avatar.svg">
                </div>
                <div class="info">
                    <div class="author">
                        <span class="name">付心武士</span>
                        
                            <span class="author-label">Lv3</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fas fa-edit"></i>&nbsp;
        <span class="pc">2022-01-06 15:08:00</span>
        <span class="mobile">2022-01-06 15:08</span>
    </span>
    
        <span class="article-categories article-meta-item">
            <i class="fas fa-folder"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/categories/%E6%8A%80%E6%9C%AF/">技术</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fas fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/tags/unity/">unity</a>&nbsp;
                    </li>
                
                    <li>
                        | <a href="/tags/quickgame/">quickgame</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fas fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                    </div>
                </div>
            </div>
        

        <div class="article-content markdown-body">
            <h2 id="已知问题"><a href="#已知问题" class="headerlink" title="已知问题"></a>已知问题</h2><ul>
<li>unity默认字体在OPPO小游戏上不支持中文，英文正常显示，中文直接不显示</li>
<li>OPPO小游戏打包工具生成的包名为：com.<Company Name>.<Product Name>。Company Name 和Product Name为unity-Player Settings中设置的包名和应用名。可以通过修改OPPO小游戏目录中manifest.json文件然后重新导出rpk实现包名的修改。</li>
</ul>
<h2 id="Unity中调用OPPO平台API"><a href="#Unity中调用OPPO平台API" class="headerlink" title="Unity中调用OPPO平台API"></a>Unity中调用OPPO平台API</h2><ul>
<li>unity项目Assets/Plugins目录下新建后缀为.jslib文件</li>
<li>.jslib文件实现OPPO平台API的调用，并回调C#文件</li>
</ul>
<p>.jslib文件:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br></pre></td><td class="code"><pre><span class="line">mergeInto(LibraryManager.library, &#123;</span><br><span class="line"></span><br><span class="line">  InitSDK: function (adUnitId, type) &#123;</span><br><span class="line">    const qg = window.qg;//qg OPPO 小游戏平台提供的全局对象</span><br><span class="line">    if (qg) &#123;</span><br><span class="line">      console.log(&quot;-------window.qg 存在&quot;)</span><br><span class="line">      var systemInfo = qg.getSystemInfoSync();</span><br><span class="line">      console.log(systemInfo);</span><br><span class="line">      switch (Pointer_stringify(type)) &#123;</span><br><span class="line">        case &quot;banner&quot;:</span><br><span class="line">          var bannerAd = qg.createBannerAd(&#123;</span><br><span class="line">            adUnitId: Pointer_stringify(adUnitId), //字符串需要转换一下</span><br><span class="line">            style: &#123;</span><br><span class="line">              left: 0,</span><br><span class="line">              top: systemInfo.screenHeight - 100 - 10,</span><br><span class="line">              width: systemInfo.screenWidth,</span><br><span class="line">              height: 50</span><br><span class="line">            &#125;</span><br><span class="line">          &#125;);</span><br><span class="line">          if (!window.OPPOAD) &#123;</span><br><span class="line">            window.OPPOAD = &#123;&#125;;</span><br><span class="line">          &#125;</span><br><span class="line">          window.OPPOAD.bannerAd = bannerAd;</span><br><span class="line">          break;</span><br><span class="line">        case &quot;video&quot;:</span><br><span class="line">          var videoAd = qg.createRewardedVideoAd(&#123;</span><br><span class="line">            adUnitId: Pointer_stringify(adUnitId)</span><br><span class="line">          &#125;)</span><br><span class="line">          if (!window.OPPOAD) &#123;</span><br><span class="line">            window.OPPOAD = &#123;&#125;;</span><br><span class="line">          &#125;</span><br><span class="line">          window.OPPOAD.videoAd = videoAd;</span><br><span class="line">          break;</span><br><span class="line">        case &quot;gameBanner&quot;:</span><br><span class="line">          // var gameBannerAd = qg.createGameBannerAd(&#123;</span><br><span class="line">          //   adUnitId: Pointer_stringify(adUnitId)</span><br><span class="line">          // &#125;)</span><br><span class="line">          break;</span><br><span class="line">        default:</span><br><span class="line">          break;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125; else &#123;</span><br><span class="line">      SendMessage(&#x27;BtnRoot&#x27;, &#x27;CallBack&#x27;, &#x27;init failed  mybe not OPPO-quickgame&#x27;); //组件名，方法名，参数</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  JSShowBannerAd: function () &#123;</span><br><span class="line">    if (window.OPPOAD &amp;&amp; window.OPPOAD.bannerAd) &#123;</span><br><span class="line">      const bannerAd = window.OPPOAD.bannerAd;</span><br><span class="line">      console.log(&quot;-------bannerAd.show()&quot;);</span><br><span class="line">      bannerAd.show();</span><br><span class="line">      bannerAd.onLoad(function () &#123;</span><br><span class="line">        console.log(&#x27;banner 广告加载成功&#x27;)</span><br><span class="line">        SendMessage(&#x27;BtnRoot&#x27;, &#x27;CallBack&#x27;, &#x27;bannerAd load success&#x27;);</span><br><span class="line">      &#125;);</span><br><span class="line">      bannerAd.onError(function (err) &#123;</span><br><span class="line">        console.log(&quot;this.bannerAd   onError&quot;, res);</span><br><span class="line">      &#125;);</span><br><span class="line">    &#125; else &#123;</span><br><span class="line">      console.log(&quot;------- no bannerAd&quot;);</span><br><span class="line">    &#125;;</span><br><span class="line"></span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  JSHideBannerAd: function () &#123;</span><br><span class="line">    if (window.OPPOAD &amp;&amp; window.OPPOAD.bannerAd) &#123;</span><br><span class="line">      const bannerAd = window.OPPOAD.bannerAd;</span><br><span class="line">      console.log(&quot;-------bannerAd.hide()&quot;);</span><br><span class="line">      bannerAd.hide();</span><br><span class="line">      bannerAd.onHide(function () &#123;</span><br><span class="line">        console.log(&#x27;banner 广告隐藏&#x27;)</span><br><span class="line">        SendMessage(&#x27;BtnRoot&#x27;, &#x27;CallBack&#x27;, &#x27;bannerAd hide&#x27;);</span><br><span class="line">      &#125;);</span><br><span class="line">    &#125; else &#123;</span><br><span class="line">      console.log(&quot;------- no bannerAd&quot;);</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  JSShowVideoAd: function () &#123;</span><br><span class="line">    if (window.OPPOAD &amp;&amp; window.OPPOAD.videoAd) &#123;</span><br><span class="line">      const videoAd = window.OPPOAD.videoAd;</span><br><span class="line">      videoAd.load();</span><br><span class="line">      videoAd.onLoad(function () &#123;</span><br><span class="line">        console.log(&#x27;激励视频加载成功&#x27;)</span><br><span class="line">        videoAd.show()</span><br><span class="line">      &#125;);</span><br><span class="line">      videoAd.onClose(function(res) &#123;</span><br><span class="line">        if (res.isEnded) &#123;</span><br><span class="line">          console.log(&#x27;激励视频广告完成，发放奖励&#x27;);</span><br><span class="line">          SendMessage(&#x27;BtnRoot&#x27;, &#x27;CallBack&#x27;, &#x27;videoAd isEnded, Rewarded&#x27;);</span><br><span class="line">        &#125; else &#123;</span><br><span class="line">          console.log(&#x27;激励视频广告取消关闭，不发放奖励&#x27;);</span><br><span class="line">          SendMessage(&#x27;BtnRoot&#x27;, &#x27;CallBack&#x27;, &#x27;videoAd cancle, no Rewarded&#x27;);</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;);</span><br><span class="line">    &#125; else &#123;</span><br><span class="line">      console.log(&quot;------- no videoAd&quot;);</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">  JSVibrateShort: function () &#123;//震动</span><br><span class="line">    if (window.qg) &#123;</span><br><span class="line">      qg.vibrateShort(&#123;</span><br><span class="line">        success: function (res) &#123; &#125;,</span><br><span class="line">        fail: function (res) &#123; &#125;,</span><br><span class="line">        complete: function (res) &#123;</span><br><span class="line">          console.log(&quot;-------qg.vibrateShort complete&quot;);</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;);</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<ul>
<li>C#脚本中调用.jslib文件中的方法</li>
</ul>
<p>C#脚本:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br></pre></td><td class="code"><pre><span class="line">using System.Collections;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using UnityEngine;</span><br><span class="line">using System.Runtime.InteropServices;</span><br><span class="line">using System;</span><br><span class="line">using UnityEngine.UI;</span><br><span class="line"></span><br><span class="line">public class SDKHelper : MonoBehaviour</span><br><span class="line">&#123;</span><br><span class="line">    [DllImport(&quot;__Internal&quot;)]</span><br><span class="line">    private static extern void InitSDK(string id, string tag);</span><br><span class="line">    [DllImport(&quot;__Internal&quot;)]</span><br><span class="line">    private static extern void JSShowBannerAd();</span><br><span class="line">    [DllImport(&quot;__Internal&quot;)]</span><br><span class="line">    private static extern void JSHideBannerAd();</span><br><span class="line">    [DllImport(&quot;__Internal&quot;)]</span><br><span class="line">    private static extern void JSShowVideoAd();</span><br><span class="line">    [DllImport(&quot;__Internal&quot;)]</span><br><span class="line">    private static extern void JSVibrateShort();</span><br><span class="line"></span><br><span class="line">    [SerializeField] private Text tipText = default; </span><br><span class="line">    private string bannerAdID = &quot;355963&quot;; //Banner广告</span><br><span class="line">    private string videoAdID = &quot;355959&quot;; //激励视频广告</span><br><span class="line">    private string gameBannerAdID = &quot;355966&quot;;//互推盒子广告</span><br><span class="line"></span><br><span class="line">    //开屏广告 无需技术接入，创建开屏广告位，并更新游戏包即可自动开通开屏广告。</span><br><span class="line"></span><br><span class="line">    void Start()</span><br><span class="line">    &#123;</span><br><span class="line">        InitAD();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    private void InitAD()</span><br><span class="line">    &#123;</span><br><span class="line">        InitSDK(bannerAdID, &quot;banner&quot;);</span><br><span class="line">        InitSDK(videoAdID, &quot;video&quot;);</span><br><span class="line">        InitSDK(gameBannerAdID, &quot;gameBanner&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">    #region  按钮点击事件</span><br><span class="line">    /**banner广告*/</span><br><span class="line">    public void ShowBannerAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ ShowBannerAd&quot;);</span><br><span class="line">        JSShowBannerAd();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public void HideBannerAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ HideBannerAd&quot;);</span><br><span class="line">        JSHideBannerAd();</span><br><span class="line">    &#125;</span><br><span class="line">    /**激励视频广告*/</span><br><span class="line">    public void ShowVideoAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ ShowVideoAd&quot;);</span><br><span class="line">        JSShowVideoAd();</span><br><span class="line">    &#125;</span><br><span class="line">    /**互推盒子横幅广告*/</span><br><span class="line">    public void ShowGameBannerAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ ShowGameBannerAd&quot;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public void HideGameBannerAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ HideGameBannerAd&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">    /**互推盒子九宫格广告*/</span><br><span class="line">    public void ShowGamePortalAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ ShowGamePortalAd&quot;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public void HideGamePortalAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ HideGamePortalAd&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">    /**互推盒子抽屉广告*/</span><br><span class="line">    public void ShowGameDrawerAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ ShowGameDrawerAd&quot;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public void HideGameDrawerAd()</span><br><span class="line">    &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~ HideGameDrawerAd&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">    #endregion</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    public void CallBack(string str) &#123;</span><br><span class="line">        Debug.Log(&quot;~~~~~~~~ 我收到了JS层的调用: &quot; + str);</span><br><span class="line">        tipText.text = str;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>


<h6 id="安装OPPO小游戏工具"><a href="#安装OPPO小游戏工具" class="headerlink" title="安装OPPO小游戏工具"></a>安装OPPO小游戏工具</h6><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g @oppo-minigame/cli</span><br></pre></td></tr></table></figure>
<p>执行</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">quickgame -V   </span><br></pre></td></tr></table></figure>
<p>显示版本号则表示安装成功</p>
<h2 id="unity发布WebGL项目"><a href="#unity发布WebGL项目" class="headerlink" title="unity发布WebGL项目"></a>unity发布WebGL项目</h2><p>在unity发布的WebGl项目目录下执行</p>
<ul>
<li>unity安装WebGl Build Support</li>
<li>Player Settings设置OPPO小游戏对应的包名</li>
<li>Resolution and Presentation 选项卡下WebGL Template选择Minimal </li>
<li>Other Settings选项卡下取消勾选Auto Graphics Api，Graphics Api添加WebGl1.0，删除WebGL 2.0选项</li>
<li>publish Setting选项卡下Compression Format修改为Disabled<br>发布WebGL项目</li>
</ul>
<p>在发布出的WebGL项目下执行</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">quickgame unity</span><br></pre></td></tr></table></figure>
<p>会在同级目录下生成quickgame目录</p>
<h6 id="真机调试"><a href="#真机调试" class="headerlink" title="真机调试"></a>真机调试</h6><p>OPPO手机安装 OPPO 小游戏调试器</p>
<p>将quickgame/dist目录下的rpk文件拷贝到手机根目录下games目录中，没有games目录的新建gamse目录</p>
<p>打开小游戏调试器，选择“OPPO小游戏”，找到对应小游戏点击“秒开”</p>
<h6 id="Chrome查看日志"><a href="#Chrome查看日志" class="headerlink" title="Chrome查看日志"></a>Chrome查看日志</h6><p>手机与电脑在同一局域网下</p>
<p>devtools://devtools/bundled/inspector.html?v8only=true&amp;ws=192.168.0.13:12345/00010002-0003-4004-8005-000600070008</p>
<p>192.168.0.13 是手机IP，端口号12345或12346</p>
<p><a class="link"   target="_blank" rel="noopener" href="https://docs.unity3d.com/cn/2019.4/Manual/webgl-interactingwithbrowserscripting.html" >unity文档<i class="fas fa-external-link-alt"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://activity-cdo.heytapimage.com/cdo-activity/static/201810/26/quickgame/documentation/#/README" >OPPO文档<i class="fas fa-external-link-alt"></i></a></p>

        </div>

        

        
            <ul class="post-tags-box">
                
                    <li class="tag-item">
                        <a href="/tags/unity/">#unity</a>&nbsp;
                    </li>
                
                    <li class="tag-item">
                        <a href="/tags/quickgame/">#quickgame</a>&nbsp;
                    </li>
                
            </ul>
        

        
            <div class="article-nav">
                
                    <div class="article-prev">
                        <a class="prev"
                           rel="prev"
                           href="/2022/01/06/JS-uuid/"
                        >
                            <span class="left arrow-icon flex-center">
                              <i class="fas fa-chevron-left"></i>
                            </span>
                            <span class="title flex-center">
                                <span class="post-nav-title-item">JS生成唯一标识</span>
                                <span class="post-nav-item">Prev posts</span>
                            </span>
                        </a>
                    </div>
                
                
                    <div class="article-next">
                        <a class="next"
                           rel="next"
                           href="/2022/01/05/use-hexo/"
                        >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">使用hexo</span>
                                <span class="post-nav-item">Next posts</span>
                            </span>
                            <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        

        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2020</span>
              -
            
            2022&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">付心武士</a>
        </div>
        
            <script async  src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    <span id="busuanzi_container_site_uv">
                        Visitor Count&nbsp;<span id="busuanzi_value_site_uv"></span>&ensp;
                    </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        Totalview&nbsp;<span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="theme-info info-item">
            Powered by <a target="_blank" href="https://hexo.io">Hexo</a>&nbsp;|&nbsp;Theme&nbsp;<a class="theme-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep v3.4.5</a>
        </div>
        
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item page-aside-toggle">
                <i class="fas fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="fas fa-arrow-up"></i>
            </li>
        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
    </ul>
</div>

    </div>

    
        <aside class="page-aside">
            <div class="post-toc-wrap">
    <div class="post-toc">
        <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B7%B2%E7%9F%A5%E9%97%AE%E9%A2%98"><span class="nav-number">1.</span> <span class="nav-text">已知问题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Unity%E4%B8%AD%E8%B0%83%E7%94%A8OPPO%E5%B9%B3%E5%8F%B0API"><span class="nav-number">2.</span> <span class="nav-text">Unity中调用OPPO平台API</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#%E5%AE%89%E8%A3%85OPPO%E5%B0%8F%E6%B8%B8%E6%88%8F%E5%B7%A5%E5%85%B7"><span class="nav-number">2.0.0.0.1.</span> <span class="nav-text">安装OPPO小游戏工具</span></a></li></ol></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#unity%E5%8F%91%E5%B8%83WebGL%E9%A1%B9%E7%9B%AE"><span class="nav-number">3.</span> <span class="nav-text">unity发布WebGL项目</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#%E7%9C%9F%E6%9C%BA%E8%B0%83%E8%AF%95"><span class="nav-number">3.0.0.0.1.</span> <span class="nav-text">真机调试</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#Chrome%E6%9F%A5%E7%9C%8B%E6%97%A5%E5%BF%97"><span class="nav-number">3.0.0.0.2.</span> <span class="nav-text">Chrome查看日志</span></a></li></ol></li></ol></li></ol></li></ol></li></ol>
    </div>
</div>
        </aside>
    

    <div class="image-viewer-container">
    <img src="">
</div>


    
        <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
          <span class="search-input-field-pre">
            <i class="fas fa-keyboard"></i>
          </span>
            <div class="search-input-container">
                <input autocomplete="off"
                       autocorrect="off"
                       autocapitalize="off"
                       placeholder="Search..."
                       spellcheck="false"
                       type="search"
                       class="search-input"
                >
            </div>
            <span class="popup-btn-close">
                <i class="fas fa-times"></i>
            </span>
        </div>
        <div id="search-result">
            <div id="no-result">
                <i class="fas fa-spinner fa-pulse fa-5x fa-fw"></i>
            </div>
        </div>
    </div>
</div>

    

</main>




<script src="/js/utils.js"></script>

<script src="/js/main.js"></script>

<script src="/js/header-shrink.js"></script>

<script src="/js/back2top.js"></script>

<script src="/js/dark-light-toggle.js"></script>



    
<script src="/js/local-search.js"></script>




    
<script src="/js/code-copy.js"></script>





<div class="post-scripts">
    
        
<script src="/js/left-side-toggle.js"></script>

<script src="/js/libs/anime.min.js"></script>

<script src="/js/toc.js"></script>

    
</div>



</body>
</html>
